#include"timewheel.hpp"


class test
{
public:
    test()
    {
        std::cout<<"test--构造done"<<std::endl;
    }
    ~test()
    {
        std::cout<<"test--析构done"<<std::endl;
    }
};
void TaskFunc(test* t)
{
    delete t;
}
int main()
{
    TimeWheel wheel;
    test* t = new test;
    wheel.AddTask(1,5,std::bind(&TaskFunc,t));
    for(int i = 0;i<5;i++)
    {
        std::cout<<"-----------"<<std::endl;
        wheel.DelayTaskForTime(1);
        std::cout<<"任务被延迟1s"<<std::endl;
        sleep(1);
    }
    //测试取消任务功能
    //wheel.TimeTaskCancel(1);
    while(true)
    {
        sleep(1);
        std::cout<<"------------"<<std::endl;
        wheel.RunTimeTask();
    }
    return 0;
}